package com.yzl.frelink.entities.model;

import java.util.ArrayList;
import java.util.List;

import com.yzl.frelink.entities.chart.Parameter;
import com.yzl.frelink.entities.component.Chart;
import com.yzl.frelink.entities.component.Component;
import com.yzl.frelink.entities.component.Gate;
import com.yzl.frelink.entities.component.Port;

import lombok.Data;

@Data
public class Model {
    private String name;
    private List<Chart> charts;
    private List<Line> lines;
    private List<Port> ports;
    private List<Gate> gates;

    public Model() {
        this.name = "model";
        this.charts = new ArrayList<>();
        this.lines = new ArrayList<>();
        this.ports = new ArrayList<>();
        this.gates = new ArrayList<>();
    }

    public void addChart(Chart chart) {
        this.charts.add(chart);
    }
    public void addPort(Port port) {
        this.ports.add(port);
    }
    public void addGate(Gate gate) {
        this.gates.add(gate);
    }

    public int getChartNum() {
        return this.charts.size();
    }

    public void addLine(Line line) {
        this.lines.add(line);
    }

    public Chart getParamMaster(Parameter parameter) {
        for (Chart chart : charts) {
            if (chart.getName().equals(parameter.getMaster())) {
                return chart;
            }
        }
        return null;
    }
}
